<template>
  <div class="wrapper">
    <label>{{ label }}:</label>
    <div class="actions" v-if="isEdit">
      <input v-model="text" />
      <button @click="isEdit = !isEdit" class="edit-btn">X</button>
    </div>
    <div class="actions" v-else>
      <div>{{ content }}</div>
      <button @click="isEdit = !isEdit" class="edit-btn">√</button>
    </div>
  </div>
</template>

<script lang="ts">
import { ref } from "vue";
export default {
  props: {
    label: String,
    content: String,
  },
  setup() {
    const isEdit = ref(false);
    return {
      isEdit,
    };
  },
  data() {
    return {
      text: "",
    };
  },
};
</script>

<style lang="scss" scoped>
.wrapper {
  display: flex;
  min-width: 300px;
  padding: 0.8em 0.4em;
  margin: 1em 0;
  .actions {
    flex: 1;
    display: flex;
    & > :first-child {
      flex: 1;
    }
  }
}
</style>